
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="alternate icon" type="image/png" href="assets/i/favicon.png">
<title></title>
<link rel="stylesheet" href="assets/css/amazeui.min.css" />
<script src="js/iscroll5.js" type="text/javascript"></script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>

<script src="js/main.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>
<style type="text/css">
html,body,.page {
	height: 100%;
}

#wrapper {
	position: absolute;
	top: 49px;
	bottom: 0;
	overflow: hidden;
	margin: 0;
	width: 100%;
	padding: 0 8px;
	background-color: #f8f8f8;
}

.am-list {
	margin: 0;
}

.am-list>li {
	background: none;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.pull-action {
	text-align: center;
	height: 45px;
	line-height: 45px;
	color: #999;
}

.pull-action .am-icon-spin {
	display: none;
}

.pull-action.loading .am-icon-spin {
	display: block;
}

.pull-action.loading .pull-label {
	display: none;
}
</style>




</head>

<body>
	<header data-am-widget="header" class="am-header am-header-default">
		<div class="am-header-left am-header-nav">
			<a href="javascript:void(0)" class="" onclick="javascript:history.back()"> <i
				class="am-header-icon am-icon-chevron-left"></i> </a>
		</div>
		<h1 class="am-header-title">
			<a href="#title-link" class="">商家结果 </a>
		</h1>
	</header>
	<div class="am-list-news-bd" id="wrapper">
		<div id="pullup">
			<ul class="am-list" id="thelist">
			</ul>
		</div>
	</div>
	<!--  <div data-am-widget="list_news" class="am-list-news am-list-news-default" id="wrapper">
		<div class="am-list-news-bd">
			<ul class="am-list" id="thelist"></ul>
		</div>
	</div>-->
	<script type="text/javascript">
		$(document)
				.ready(
						function(e) {
							var mresults = window.sessionStorage
									.getItem("mresults");
							if (mresults) {
								var rows = JSON.parse(mresults);
								if (rows) {
									var content = "";
									var $rows = $(rows);
									$rows
											.each(function(key, value) {
												
												content = content
														+ '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left">';
												content += ' <div class="am-u-sm-4 am-list-thumb">';
												content += ' <a href="#"><img src="image/mdefualt.png" alt=""/> </a></div>';
												content += '<div class=" am-u-sm-8 am-list-main">';
												content += ' <h3 class="am-list-item-hd"><a href="#" class="">'
														+ value.merchantname
														+ '</a>';
												content += '<button class="am-btn am-btn-sm am-radius am-btn-secondary am-fr" onclick="toModifyMer(\''+value.merchantid+'\')">修改</button>';
												content += '</h3><div class="am-list-item-text">';
												content += value.address
														+ "</br>";
												content += value.phone
														+ "</br>";
												content += value.date + "</br>";

												content += '</div>  </div>  </li>';
											});
									$("#thelist").append(content);
									//<a href="#" data-role="button" data-inline="true" data-mini="true" data-theme="b">修改</a>

								}
							}

						});
		function toModifyMer(merchantid) {
			var reqData = new RequestData('toRegister.action');
			reqData.merchantid =merchantid;
			var jsonstr = JSON.stringify(reqData);
			$.ajax({
				cache : false,
				type : "POST",
				crossDomain : true,
				url : testUrl,
				data : jsonstr, // 你的formid
				async : false,
				error : function(request) {
					alert("Connection error");
				},
				success : function(data) {			
					var dataObj = eval("(" + data + ")");
					if (dataObj.ret == 1) {
						var jsonObj = JSON.stringify(dataObj.params);
						window.sessionStorage.setItem("opt", "modify");
						window.sessionStorage.setItem("mdetail", jsonObj);	
						window.sessionStorage.setItem("merchantid", merchantid);			
						toPage("mregister1.html");
					}
			}
		});	
		}
	var generatedCount = 0;
	var curPageNo=2;
	function requestServer() {
		var reqData = new RequestData('listMerchant.action');
		var opt =getQueryString('opt');
		reqData.registerflag = 0;
		reqData.recordalflag = 0;
		if (opt == 1) {
			reqData.registerflag = 1;
		} else if(opt == 0){
			reqData.recordalflag = 1;
		}
		reqData.pageindex = curPageNo;
		reqData.itemsperpage = 10;
		var jsonstr = JSON.stringify(reqData);
		var content="";
		$.ajax({
			cache : false,
			type : "POST",
			crossDomain : true,
			url : testUrl,
			data : jsonstr, // 你的formid
			async : false,
			error : function(request) {
				alert("Connection error");
			},
			success : function(data) {
				var dataObj = eval("(" + data + ")");
				if (dataObj.ret == 1) {
					curPageNo++;
					var rows = dataObj.rows;
					var $rows = $(rows);			
					$rows.each(function(key, value) {
						
						content = content + '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left">';
						content +=' <div class="am-u-sm-4 am-list-thumb">';
						if(value.url){
							content +=' <a href="#"><img src="'+value.url+'" alt=""/> </a></div>';
						}else{
							content +=' <a href="#"><img src="image/mdefualt.png" alt=""/> </a></div>';
						}				
						content +='<div class=" am-u-sm-8 am-list-main">';
						content +=' <h3 class="am-list-item-hd"><a href="#" class="">' + value.merchantname+'</a>';
							content +='<button class="am-btn am-btn-secondary am-fr" onclick="toModifyMer(\''+value.merchantid+'\')">修改</button></h3>';
						content +='<div class="am-list-item-text">';
						content +=  value.address + "</br>";
						content +=  value.phone + "</br>";
						content +=  value.date+"</br>";
					
						content += '</div>  </div>  </li>';	
					});
				}

			}
		});
		return content;
	}
	function pullUpAction(theScroller) {
		setTimeout(
				function() {
					var el, li, i;
					el = document.getElementById('thelist');		
						var content=requestServer();					
						$("#thelist").append(content);
						
					theScroller.refresh();
				}, 500);
	}

	var IScrollPullUpDown = function(wrapperName, iScrollConfig,
			pullUpActionHandler) {
		var iScrollConfig, pullUpActionHandler, pullDownEl, pullDownOffset, pullUpEl, scrollStartPos;
		var pullThreshold = 5;
		var me = this;

		function showPullDownElNow(className) {
			pullDownEl.style.transitionDuration = '';
			pullDownEl.style.marginTop = '';
			pullDownEl.className = 'pullDown ' + className;
		}
		var hidePullDownEl = function(time, refresh) {
			pullDownEl.style.transitionDuration = (time > 0 ? time + 'ms' : '');
			pullDownEl.style.marginTop = '';
			pullDownEl.className = 'pullDown scrolledUp';
			if (refresh)
				setTimeout(function() {
					me.myScroll.refresh();
				}, time + 10);
		}

		function init() {
			var wrapperObj = document.querySelector('#' + wrapperName);
			var scrollerObj = wrapperObj.children[0];
			if (pullUpActionHandler) {
				pullUpEl = document.createElement('div');
				pullUpEl.className = 'pullUp';
				pullUpEl.innerHTML = '<span class="pullUpIcon"></span><span class="pullUpLabel">Pull up to load more...</span>';
				scrollerObj.appendChild(pullUpEl);
			}
			me.myScroll = new IScroll(wrapperObj, iScrollConfig);

			me.myScroll
					.on(
							'refresh',
							function() {
								if ((pullDownEl)
										&& (pullDownEl.className
												.match('loading'))) {
									pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
									if (this.y >= 0) {
										hidePullDownEl(250, true);

									} else if (this.y > -pullDownOffset) {
										pullDownEl.style.marginTop = this.y
												+ 'px';
										pullDownEl.offsetHeight;
										var animTime = (250 * (pullDownOffset + this.y) / pullDownOffset);
										this.scrollTo(0, 0, 0);
										setTimeout(function() {
											hidePullDownEl(animTime, true);
										}, 0);

									} else {
										hidePullDownEl(0, true);
										this.scrollBy(0, pullDownOffset, 0);
									}
								}
								if ((pullUpEl)
										&& (pullUpEl.className.match('loading'))) {
									pullUpEl.className = 'pullUp';
									pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
								}
							});

			me.myScroll.on('scrollStart', function() {
				scrollStartPos = this.y;
			});

			me.myScroll
					.on(
							'scroll',
							function() {
								if (pullDownEl || pullUpEl) {
									if ((scrollStartPos == 0) && (this.y == 0)) {
										this.hasVerticalScroll = true;
										scrollStartPos = -1000;
									} else if ((scrollStartPos == -1000)
											&& (((!pullUpEl)
													&& (!pullDownEl.className
															.match('flip')) && (this.y < 0)) || ((!pullDownEl)
													&& (!pullUpEl.className
															.match('flip')) && (this.y > 0)))) {
										this.hasVerticalScroll = false;
										scrollStartPos = 0;
										this.scrollBy(0, -this.y, 0);
									}
								}

								if (pullDownEl) {
									if (this.y > pullDownOffset + pullThreshold
											&& !pullDownEl.className
													.match('flip')) {
										showPullDownElNow('flip');
										this.scrollBy(0, -pullDownOffset, 0);
										pullDownEl
												.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
									} else if (this.y < 0
											&& pullDownEl.className
													.match('flip')) { // User changes his mind...
										hidePullDownEl(0, false);
										this.scrollBy(0, pullDownOffset, 0);
										pullDownEl
												.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
									}
								}
								if (pullUpEl) {
									if (this.y < (this.maxScrollY - pullThreshold)
											&& !pullUpEl.className
													.match('flip')) {
										pullUpEl.className = 'pullUp flip';
										pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Release to load more...';
									} else if (this.y > (this.maxScrollY + pullThreshold)
											&& pullUpEl.className.match('flip')) {
										pullUpEl.className = 'pullUp';
										pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
									}
								}
							});

			me.myScroll
					.on(
							'scrollEnd',
							function() {

								if ((pullUpEl)
										&& (pullUpEl.className.match('flip'))) {
									pullUpEl.className = 'pullUp loading';
									pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...';
									pullUpActionHandler(this);
								}
								if (scrollStartPos = -1000) {
									this.hasVerticalScroll = this.options.scrollY
											&& this.maxScrollY < 0;
								}
							});

		}
		window.addEventListener('load', function() {
			init()
		}, false);
	};
	var scroller1 = new IScrollPullUpDown('wrapper', {
		probeType : 2,
		bounceTime : 250,
		bounceEasing : 'quadratic',
		mouseWheel : false,
		scrollbars : true,
		fadeScrollbars : true,
		interactiveScrollbars : false
	}, pullUpAction);

	document.addEventListener('touchmove', function(e) {
		e.preventDefault();
	}, false);

	</script>
</body>
</html>